package com.neusoft.clouduserfeign.feign;

import com.neusoft.clouduserfeign.config.FeignConfig;
import com.neusoft.clouduserfeign.dto.Employee;
import com.neusoft.clouduserfeign.dto.EmployeeVO;
import com.neusoft.clouduserfeign.dto.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 员工服务Feign客户端
 * 通过负载均衡调用员工服务接口
 */
@FeignClient(
    name = "cloud-user-service",
    contextId = "employeeServiceClient",
    path = "/api/employees",
    fallback = EmployeeServiceClientFallback.class,
    configuration = FeignConfig.class
)
public interface EmployeeServiceClient {

    /**
     * 创建员工
     */
    @PostMapping
    Result<Void> createEmployee(@RequestBody Employee employee, @RequestParam("createBy") String createBy);

    /**
     * 更新员工信息
     */
    @PutMapping("/{userId}")
    Result<Void> updateEmployee(@PathVariable("userId") String userId,
                               @RequestBody Employee employee,
                               @RequestParam("updateBy") String updateBy);

    /**
     * 删除员工（逻辑删除）
     */
    @DeleteMapping("/{userId}")
    Result<Void> deleteEmployee(@PathVariable("userId") String userId, @RequestParam("updateBy") String updateBy);

    /**
     * 更新员工状态
     */
    @PutMapping("/{userId}/status")
    Result<Void> updateEmployeeStatus(@PathVariable("userId") String userId,
                                     @RequestParam("status") String status,
                                     @RequestParam("updateBy") String updateBy);

    /**
     * 根据用户ID获取员工详细信息（包含用户基本信息）
     */
    @GetMapping("/user/{userId}")
    Result<EmployeeVO> getEmployeeByUserId(@PathVariable("userId") String userId);

    /**
     * 根据员工工号获取员工详细信息（包含用户基本信息）
     */
    @GetMapping("/no/{employeeNo}")
    Result<EmployeeVO> getEmployeeByEmployeeNo(@PathVariable("employeeNo") String employeeNo);

    /**
     * 查询员工详细信息列表（包含用户基本信息）
     */
    @GetMapping
    Result<List<EmployeeVO>> getEmployeeList(@RequestParam(value = "deptName", required = false) String deptName,
                                            @RequestParam(value = "status", required = false) String status,
                                            @RequestParam(value = "keyword", required = false) String keyword);

    /**
     * 根据部门查询员工详细信息列表（包含用户基本信息）
     */
    @GetMapping("/dept/{deptName}")
    Result<List<EmployeeVO>> getEmployeesByDept(@PathVariable("deptName") String deptName);

    /**
     * 根据上级ID查询下属员工详细信息列表（包含用户基本信息）
     */
    @GetMapping("/manager/{managerId}")
    Result<List<EmployeeVO>> getEmployeesByManager(@PathVariable("managerId") String managerId);

    /**
     * 生成员工工号
     */
    @GetMapping("/generate-no")
    Result<String> generateEmployeeNo();

    /**
     * 检查员工工号是否存在
     */
    @GetMapping("/check-no/{employeeNo}")
    Result<Boolean> checkEmployeeNoExists(@PathVariable("employeeNo") String employeeNo);
}
